using System;
using System.Collections.Generic;
using System.Text;
using Musicman.Entities.BusinessEntities;

namespace Musicman.Entities
{
	public class Searchfolder
	{
		private long? searchfolderid;
		private int? searchlocationid;
		private string name;
		private DateTime? changetime;
        private SearchFileCollection files;
        private Searchlocation searchLocation;

        public Searchfolder(Searchlocation parent)
        {
            this.SearchLocation = parent;
            this.Searchlocationid = parent.Searchlocationid;
            this.files = new SearchFileCollection();
        }

        public Searchfolder()
        {
            this.files = new SearchFileCollection();
        }

        public void AddSearchFile(Searchfile file)
        {
            file.Folder = this;
            file.Searchfolderid = this.searchfolderid;
            files.Add(file);
        }

        public void CopyProperties(Searchfolder folder)
        {
            this.name = folder.name;
            this.changetime = folder.changetime;
        }

        public void RemoveSearchFile(Searchfile file)
        {
            files.Remove(file);
        }

		public long? Searchfolderid
		{
			get { return searchfolderid; }
			set 
            { 
                this.searchfolderid = value;
                for (int i=0; i <files.Count; i++)
                {
                    files[i].Searchfolderid = value;
                }
            }
		}
            
        public int? Searchlocationid
		{
			get { return searchlocationid; }
			set { this.searchlocationid = value; }
		}

		public string Name
		{
			get { return name; }
			set { this.name = value; }
		}

		public DateTime? Changetime
		{
			get { return changetime; }
			set { this.changetime = value; }
		}

        public List<Searchfile> Files
        {
            get { return files.InnerList; }
        }

        public Searchlocation SearchLocation
        {
            get { return searchLocation; }
            set { searchLocation = value; }
        }

	}
}
